/*
 * @Author: wangdian
 * @Date: 2023-06-15 15:38:35
 * @LastEditors: wangdian
 * @LastEditTime: 2023-06-15 15:48:51
 * @Description: file content
 * @FilePath: \koa\server.js
 */
//因为我们需要用到koa，所以我们先进行获取
const koa = require('koa');  //引入koa
var route = require('koa-route'); //require it
var app = new koa();
//and we'll set up 2 routes, for our index and about me pages
app.use(route.get('/', index));
app.use(route.get('/about', about));


function* index() {
    this.body = "<h1>Hello! This is my home page!</h1>";
}
function* about() {
    this.body = "<h2>My name is Adam and I like JavaScript</h2>";
}
app.listen(8008);
console.log('Koa listening on port 8008');